package 蓝桥真题;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class 游园安排 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=1000010;
       static char[]str=null;
       static int pt[]=new int[N],lr[]=new int[N],n,cnt;
       static String[]a=new String[N];
       public static void main(String[] args) throws IOException {
		      str=br.readLine().toCharArray();
		      n=str.length;
		      int idx;
		      StringBuffer sb=new StringBuffer();
		      sb.append(str[0]);
		      for(int i=1;i<n;i++){
		    	  if(str[i]>='A'&&str[i]<='Z'){
		    		  a[cnt++]=sb.toString();
		    		  sb.delete(0,11);
		    	  }
		    	  sb.append(str[i]);
		      }
		      a[cnt++]=sb.toString();
		      a[cnt]="0";
		      lr[0]=cnt;
		      int len =0;
		      for(int i=0;i<cnt;i++){    
		    	  int l=0,r=len;
		    	  while(l<r){
		    		  int mid=l+r+1>>1;
		    	      if(a[lr[mid]].compareTo(a[i])<0)
		    	    	  l=mid;
		    	      else r=mid-1;
		    	  }
		    	  len=Math.max(len, r+1);
		    	  pt[i]=lr[r];
		    	  lr[r+1]=i;
		      }
		      int k=lr[len];
		      String res="";
		      while(!a[k].equals("0")){
		    	  res=a[k]+res;
		    	  k=pt[k];
		      }
		      System.out.print(res);
		      
	}
} 